import 'package:dio/dio.dart';
import 'package:flutter_enjoy_plus_seven/constants/index.dart';
import 'package:flutter_enjoy_plus_seven/utils/RequestDio.dart';

class UserApi {
  /// 发送验证码
  static Future sendCode(String mobile) {
    return requestDio.get(HTTP_PATH.SEND_CODE, params: {'mobile': mobile});
  }

  /// 登录-手机号+验证码登录
  static Future login(String mobile, String code) {
    return requestDio
        .post(HTTP_PATH.LOGIN, data: {'mobile': mobile, 'code': code});
  }

  /// 获取用户信息
  static Future getUserInfo() {
    return requestDio.get(HTTP_PATH.USER_INFO);
  }

  /// 更新用户信息
  static Future updateUserInfo(String nickName) {
    return requestDio.put(HTTP_PATH.USER_INFO, data: {'nickName': nickName});
  }

  /// 上传图片或者头像
  static Future uploadPhoto(FormData data) {
    return requestDio.upload(HTTP_PATH.UPLOAD, data: data);
  }
}
